This lab is intended to give you a taste of hardening software in Linux. It is neither an exhaustive list of recommendations nor even a list of things that apply to all systems. It is simply meant to give you practice in changing software settings and testing those changes.
This lab counts for marks. Submit your results and screenshots as per instructions posted on Blackboard. For the screenshots, you only need to include enough in your screenshots to show your bash prompt, the command you ran, and the output that demonstrates what you did or that the command works. For the roundcube
web page screenshot, you only need to show the login succeeded as there is no email in the account.
Following the example in the slides, modify your sudo
executable to only be accessible for execution by the file owner and the file’s group
sudo dpkg-statoverride --update --add root sudo 4550 /usr/bin/sudo
sudo dpkg-statoverride --update --add root sudo 4550 /usr/bin/sudo
Before exiting your current bash session, start a second terminal window and ensure you can still use sudo
Does debsums
complain about your modified sudo
program? How about dpkg
with the verify option? - submission question!
debsums sudo | grep /usr/bin/sudo sudo dpkg --verify sudo
debsums sudo | grep /usr/bin/sudo
sudo dpkg --verify sudo
Use the list option of dpkg-statoverride
to view all programs with overrides on your system - screenshot!
dpkg-statoverride --list
dpkg-statoverride --list
Run aa-status
to see what the current state of apparmor
is on your VM
sudo aa-status
sudo aa-status
apparmor-utils
to get access to these utilitiesTry the aa-unconfined
utility to see what processes are running that have tcp
or udp
ports and their apparmor
status
sudo aa-unconfined
sudo aa-unconfined
Review the list of profiles contained in the Ubuntu 24.04 apparmor-profiles package list of files package. Are there profiles in that package for the /etc/apparmor.d
directory which would confine software that is running unconfined on your system now? - submission question!
Try using the –paranoid option for aa-unconfined
to see if there are processes which could be confined by the apparmor-profiles
package which aa-unconfined
did not show without that option
sudo aa-unconfined --paranoid
sudo aa-unconfined --paranoid
Review the content of the apprmor
profile for the tcpdump
network snooping program
# Needed to look at "/etc/apparmor.d/usr.bin.tcpdump" line by line and explain what each line or each section of the code does. cat /etc/apparmor.d/usr.bin.tcpdump
# Needed to look at "/etc/apparmor.d/usr.bin.tcpdump" line by line and explain what each line or each section of the code does.
cat /etc/apparmor.d/usr.bin.tcpdump
Using the apparmor
man page, determine the kinds of limitations that are placed on that program by the profile. Explain the lines and be specific about the capabilities and permissions given. - submission question!
sudo
ConfigurationDigital Ocena’s tips page for sudo privileges is a helpful resource when looking for how to edit sudo
permissions.
Modify your sudo
executable to be accessible for execution by any user, so that we can use the sudoers
file to control access instead
sudo dpkg-statoverride --update --add root sudo 4555 /usr/bin/sudo
sudo dpkg-statoverride --update --add root sudo 4555 /usr/bin/sudo
Modify your /etc/sudoers
file to limit the dennis
account so that they can only use root sudo
to edit their own domain zone file (/etc/bind/db.server45678.mytld
) and reload named using the rndc reload
command. Provide a screenshot of your modified configurations - screenshot!
visudo
visudo
In a second ssh session, login as user dennis
(password is dennis
) and verify that user dennis
can use sudo
to edit their zone file and to run rndc reload
but cannot use sudo
to run another command, such as bash
(User should NOT be able to do sudo
to run any other commands!)
dennis$ sudo vi /etc/bind/db.server45678.mytld dennis$ sudo rndc reload dennis$ sudo bash
dennis$ sudo vi /etc/bind/db.server45678.mytld
dennis$ sudo rndc reload
dennis$ sudo bash
List out the sudo
configuration for user dennis
- screenshot!
dennis$ sudo -l
dennis$ sudo -l
dennis
is only capable of modifying the specified file and nothing else.Following the information given in "Security Configuration" of the Bind9 Administrator’s Reference Manual (ARM), secure your bind service by:
bogusnets acl
as shown in the ARM (in /etc/bind/named.conf.options
)allow-query
, allow-recursion
, and blackhole
directives as shown in the ARM (in /etc/bind/named.conf.options
)named.conf.local
)Verify your DNS service reloads the new configuration properly, and that your domain lookup still works:
sudo rndc reload nslookup www.server45678.mytld
sudo rndc reload
nslookup www.server45678.mytld
Provide Screenshots of the following: - screenshots
a. Screenshot/contents of modified /etc/bind/named.conf.local
file
b. Screenshot/contents of modified /etc/bind/named.conf.options
file
c. Screenshot of bind9
service status: sudo service bind9 status
d. In a terminal or powershell window on your host laptop/computer, run nslookup www.server45678.mytld ip-of-your-vm
to verify your domain service is still available to non-local clients
Run the mysql_secure_installation
script to clean up after the install - screenshot!
root
mysql_secure_installation
about the authentication method as follows:ali@pc12345678:~$ sudo mysql_secure_installation Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server # This is probably because your MySQL server is not using "mysql_native_password" # You can login to MySQL Server and change the root account authentication using the following method: ali@pc12345678:~$ sudo mysql [sudo] password for ali: ### < output redacted for clarity > mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root'; Query OK, 0 rows affected (0.02 sec) mysql> exit Bye
ali@pc12345678:~$ sudo mysql_secure_installation
Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server
# This is probably because your MySQL server is not using "mysql_native_password"
# You can login to MySQL Server and change the root account authentication using the following method:
ali@pc12345678:~$ sudo mysql
[sudo] password for ali:
### < output redacted for clarity >
mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
Access the web page at http://your-vm-ip/roundcube
and put in the student account name and password, server localhost
to verify that the mysql
database service is still running properly - screenshot!
Emails clients may try to transmit usernames and passwords in clear text. Depending on the client software, there is no guarantee that all clients will check supported protocols and will use encryption by default when attempting to connect to the server. An external email client should not be able to attempt a connection using unencrypted protocols if it can be helped. Additionally, we do have an internal email client, Roundcube
, that uses IMAP
locally.
POP3
and disallow IMAP
from being accessed by remote hosts, and enforce POP3S
and IMAPS
services. - submission question!sudo ss -tlpn | grep dovecot
- screenshotRoundcube
at http://your-vm-ip/roundcube
and view a user mailbox. - screenshotPOP3S
and IMAPS
? Provide commands or output snippets from your firewall configuration - submission question!php
script that you can run locally on your system as POC (Proof Of Concept) in your terminal on your LabVM. You only need the php script, and nothing else since you do have a working server (you do not need docker install): https://github.com/fearsoff-org/CVE-2025-49113
php your_script.php
#!/bin/bash # simple script to identify files that are executable (programs) which did not come form installed system packages # could be improved in a number of ways IFS=$'\xa' find / -type f -executable >/tmp/filelist.$$ for file in $(cat /tmp/filelist.$$); do dpkg -S "$file" >/dev/null 2>/dev/null || echo "$file" done rm /tmp/filelist.$$
#!/bin/bash
# simple script to identify files that are executable (programs) which did not come form installed system packages
# could be improved in a number of ways
IFS=$'\xa'
find / -type f -executable >/tmp/filelist.$$
for file in $(cat /tmp/filelist.$$); do
dpkg -S "$file" >/dev/null 2>/dev/null || echo "$file"
done
rm /tmp/filelist.$$